package aplicacao.atender.chamadas;

public class MachineCall {

  public static final void main(String args[]) {

    /*
     * Create a provider by first obtaining the default implementation of
     * JTAPI and then the default provider of that implementation.
     */
    Provider myprovider = null;
    try {
      JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
      myprovider = peer.getProvider(null);
    } catch (Exception excp) {
      System.out.println("Can't get Provider: " + excp.toString());
      System.exit(0);
    }

    /*
     * Locate the Terminal associated with our near end and place a call
     * observer on it. This will instruct the implementation to add a call
     * observer once a telephone call comes to the Terminal. We are assuming
     * Terminals are named after a primary telephone number on that Terminal.
     */
    Terminal terminal;

    try {
      terminal = myprovider.getTerminal("4761111");
      terminal.addCallObserver(new MachineCallObserver());
    } catch (Exception excp) {
      // Handle all Exceptions
    }
  }
}
